package yaty.lee.tencent.weibo.util;

import java.util.logging.Logger;

import yaty.lee.tencent.weibo.domain.OAuthError;
import yaty.lee.tencent.weibo.exception.AuthException;

public class OAuthDetectUtil {
    private static final Logger log = Logger.getLogger(OAuthDetectUtil.class.getName());

    public static void detect(String msg) {
        OAuthError error = HttpURLConnectionUtil.urlParamAnalysis(msg, OAuthError.class);
        log.info("检测到OAuth错误码: " + error.getErrorCode());

        switch (error.getErrorCode()) {
        case 0:
            break;
        default:
            throw new AuthException("Auth错误码:" + error.getErrorCode() + ", 错误说明: " + error.getErrorMsg());
        }

    }
}
